<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Receipt_history_model extends CI_Model
{
    public function __construct()
    {
        parent::__construct();
    }

    public function get(){
      $sql = "SELECT aa.`acct_num`,
       aa.`acct_name`,
       ar.`receipt_number`,
       ui.invoice_num,
       (SELECT SUM(line_amt) FROM ubs_invoice_lines WHERE invoice_id = ui.`invoice_id`) invoice_amt,
       ap.pay_amount
        FROM ar_payments ap
  JOIN ar_account aa ON aa.`account_id` = ap.`account_id`
  JOIN ubs_invoices ui ON ui.`invoice_id` = ap.`invoice_id`
  JOIN ar_receipt ar ON ar.`receipt_id` = ap.`receipt_id`";
      $q = $this->db->query($sql);
      return $q->result();
    }
}